package com.ruoyi.tcsp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.tcsp.domain.bean.req.TcspTechReq;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tcsp.service.ITcspTechReqService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 技术需求Controller
 * 
 * @author rwt
 * @date 2025-04-17
 */
@RestController
@RequestMapping("/tcsp/techreq")
public class TcspTechReqController extends BaseController
{
    @Autowired
    private ITcspTechReqService tcspTechReqService;

    /**
     * 查询技术需求列表
     */
    @PreAuthorize("@ss.hasPermi('tcsp:techreq:list')")
    @GetMapping("/list")
    public TableDataInfo list(TcspTechReq tcspTechReq)
    {
        startPage();
        List<TcspTechReq> list = tcspTechReqService.selectTcspTechReqList(tcspTechReq);
        return getDataTable(list);
    }

    /**
     * 导出技术需求列表
     */
    @PreAuthorize("@ss.hasPermi('tcsp:techreq:export')")
    @Log(title = "技术需求", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TcspTechReq tcspTechReq)
    {
        List<TcspTechReq> list = tcspTechReqService.selectTcspTechReqList(tcspTechReq);
        ExcelUtil<TcspTechReq> util = new ExcelUtil<TcspTechReq>(TcspTechReq.class);
        util.exportExcel(response, list, "技术需求数据");
    }

    /**
     * 获取技术需求详细信息
     */
    @PreAuthorize("@ss.hasPermi('tcsp:techreq:query')")
    @GetMapping(value = "/{techReqId}")
    public AjaxResult getInfo(@PathVariable("techReqId") Long techReqId)
    {
        return success(tcspTechReqService.selectTcspTechReqByTechReqId(techReqId));
    }

    /**
     * 新增技术需求
     */
    @PreAuthorize("@ss.hasPermi('tcsp:techreq:add')")
    @Log(title = "技术需求", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TcspTechReq tcspTechReq)
    {
        return toAjax(tcspTechReqService.insertTcspTechReq(tcspTechReq));
    }

    /**
     * 修改技术需求
     */
    @PreAuthorize("@ss.hasPermi('tcsp:techreq:edit')")
    @Log(title = "技术需求", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TcspTechReq tcspTechReq)
    {
        return toAjax(tcspTechReqService.updateTcspTechReq(tcspTechReq));
    }

    /**
     * 删除技术需求
     */
    @PreAuthorize("@ss.hasPermi('tcsp:techreq:remove')")
    @Log(title = "技术需求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{techReqIds}")
    public AjaxResult remove(@PathVariable Long[] techReqIds)
    {
        return toAjax(tcspTechReqService.deleteTcspTechReqByTechReqIds(techReqIds));
    }
}
